package cn.dyw.shop.model;
// Generated 2018-5-12 11:41:53 by Hibernate Tools 5.1.0.Alpha1

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonManagedReference;

import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Goods generated by hbm2java
 */
@JsonIgnoreProperties(value={"handler", "hibernateLazyInitializer", "fieldHandler"})
@Entity
@Table(name = "goods", catalog = "shop")
public class Goods implements java.io.Serializable {

	private Integer id;
	private Category category;
	private Merchant merchant;
	private String name;
	private String detail;
	private BigDecimal price;
	private Integer salesVolume;
	private Integer stock;
	private String prc;
	private Boolean del;
	private Set<OrderItem> orderItems = new HashSet<OrderItem>(0);
	private Set<ShoppingCart> shoppingCarts = new HashSet<ShoppingCart>(0);

	public Goods() {
	}

	public Goods(Category category, Merchant merchant) {
		this.category = category;
		this.merchant = merchant;
	}

	public Goods(Category category, Merchant merchant, String name, String detail, BigDecimal price,
			Integer salesVolume, Integer stock, String prc, Boolean del,  Set<OrderItem> orderItems,
			Set<ShoppingCart> shoppingCarts) {
		this.category = category;
		this.merchant = merchant;
		this.name = name;
		this.detail = detail;
		this.price = price;
		this.salesVolume = salesVolume;
		this.stock = stock;
		this.prc = prc;
		this.del = del;
		this.orderItems = orderItems;
		this.shoppingCarts = shoppingCarts;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)

	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@JsonManagedReference
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "category_id", nullable = false)
	public Category getCategory() {
		return this.category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	@JsonBackReference
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "merchant_id", nullable = false)
	public Merchant getMerchant() {
		return this.merchant;
	}

	public void setMerchant(Merchant merchant) {
		this.merchant = merchant;
	}

	@Column(name = "name", length = 45)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "detail", length = 45)
	public String getDetail() {
		return this.detail;
	}

	public void setDetail(String detail) {
		this.detail = detail;
	}

	@Column(name = "price", precision = 8)
	public BigDecimal getPrice() {
		return this.price;
	}

	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	@Column(name = "sales_volume")
	public Integer getSalesVolume() {
		return this.salesVolume;
	}

	public void setSalesVolume(Integer salesVolume) {
		this.salesVolume = salesVolume;
	}

	@Column(name = "stock")
	public Integer getStock() {
		return this.stock;
	}

	public void setStock(Integer stock) {
		this.stock = stock;
	}

	@Column(name = "prc", length = 45)
	public String getPrc() {
		return this.prc;
	}

	public void setPrc(String prc) {
		this.prc = prc;
	}

	@Column(name = "del")
	public Boolean getDel() {
		return this.del;
	}

	public void setDel(Boolean del) {
		this.del = del;
	}

	@JsonBackReference
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "goods")
	public Set<OrderItem> getOrderItems() {
		return this.orderItems;
	}

	public void setOrderItems(Set<OrderItem> orderItems) {
		this.orderItems = orderItems;
	}

	@JsonBackReference
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "goods")
	public Set<ShoppingCart> getShoppingCarts() {
		return this.shoppingCarts;
	}

	public void setShoppingCarts(Set<ShoppingCart> shoppingCarts) {
		this.shoppingCarts = shoppingCarts;
	}

}
